<?php
/**
 * Created by JetBrains PhpStorm.
 * User: dino.satto
 * Date: 05/09/13
 * Time: 12:27
 * To change this template use File | Settings | File Templates.
 */



//$c=mysql_connect("localhost","root","root");

//mysql_select_db("wininternet",$c);

//$result = mysql_query("SELECT ip FROM proxy_list WHERE id={$_GET['id']}");
//$proxy_list= mysql_fetch_array($result);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "http://internetometer.com/give/33676");
	curl_setopt($ch, CURLOPT_PROXY, $_GET['ip']);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 10000);
	curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_VERBOSE, 0);

	$result = curl_exec($ch);

	curl_close ($ch);
	//echo $result;

	$dom = new DOMDocument();
	@$dom->loadHTML($result);

	$a = $dom->getElementsByTagName('input');
	$i=0;

	$chiave="";

	for ($i; $i < $a->length; $i++) {
		$attr = $a->item($i)->getAttribute('name');

		if($attr=='key'){
			$chiave = $a->item($i)->getAttribute('value');
		}
	}
	// CURLPROXY_SOCKS5   CURLPROXY_HTTP
	if($chiave!=""){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, "http://internetometer.com/give/33676");
		curl_setopt($ch, CURLOPT_PROXY,  $_GET['ip']);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 10000);
		curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
		curl_setopt($ch, CURLOPT_POSTFIELDS, "key=".$chiave);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_VERBOSE, 0);

		$result = curl_exec($ch);

		curl_close ($ch);
		//echo $result;
		echo "OK ".$_GET['ip'];
	}else{
		echo "KO ".$_GET['ip'];
	}

?>
